home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-09-06 | 2.5 KB | 107 lines | [TEXT/MACA] |
- /*
- * finder.c - finder interface routines for the game of Tablut.
- *
- */
-
- #include <quickdraw.h>
- #include <window.h>
- #include <pb.h>
- #include <segment.h>
- #include <packages.h>
- #include <memory.h>
-
- #include "tablut.h"
-
- static short dowhat; /* what the finder says to do */
- static short filecount; /* the number of files to do it to */
-
- struct launchinfo { /* stuff for launching another application */
- char *li_name; /* the name of the file to xfer to */
- long li_zip; /* magic...who knows? */
- short li_code; /* sound buf & screen magic #...use 0 */
- };
- static struct launchinfo fireprog;
- static char xfername[64]; /* the name of the file to xfer to */
-
- /*
- * quittoprog() - transfer control to a chosen application
- */
- quittoprog()
- {
- short vnum; /* volume to launch from */
-
- if (!(FileFetch(xfername, &vnum, (OSType) 'APPL'))) {
- return;
- }
- fireprog.li_name = xfername;
- fireprog.li_zip = 0;
- fireprog.li_code = 0;
- closeup();
- SetVol((char *) 0, vnum);
- /* do the asm stuff because the Manx 1.06D Launch() was buggy */
- #asm
- lea fireprog_, a0
- dc.w $a9f2
- #endasm
- ExitToShell(); /* the launch didn't work, so let's just quit */
- }
-
- /*
- * bomb() - abort the program. Most bombs should call progstop() first
- * to tell the user what went wrong.
- */
- bomb()
- {
- closeup(); ExitToShell();
- }
-
- /*
- * seeanyfiles() - read the finder file information to be used by
- * printanyfiles() and openanyfiles(),
- * returning TRUE if there are any files to process.
- */
- int
- seeanyfiles()
- {
- CountAppFiles(&dowhat, &filecount);
- return(filecount > 0);
- }
-
- /*
- * printanyfiles() - a dummy routine that would print files if
- * Tablut files could be printed.
- */
- int /* 1 == files were to be printed; 0 == no files to print */
- printanyfiles()
- {
- if (filecount == 0 || dowhat != appPrint) return(0);
- /* Silently ignore finder requests to print files */
- return(1);
- }
-
- /*
- * openanyfiles() - open any files that were requested from the finder.
- * (actually open only the first file requested.)
- */
- int /* 1 == a file was opened; 0 == none were opened */
- openanyfiles()
- {
- AppFile afile;
- int fidx; /* index of the current finder file */
-
- if (filecount == 0 || dowhat != appOpen) return(0);
- for (fidx = 1; fidx <= filecount; ++fidx) {
- GetAppFiles(fidx, &afile);
- if (afile.fType != MYFILE) continue;
- movmem((char *) &afile.fName, gamename,
- ((int) afile.fName.length & 0xFF) + 1);
- gamevnum = afile.vRefNum;
- SetWTitle(mywindow, gamename);
- if (!(needsname = !readgamefile())) {
- ClrAppFiles(fidx);
- return(1);
- }
- }
- return(0);
- }
-